part of 'page.dart';

class _LearningSettingsPageWlocStateFactory {
  const _LearningSettingsPageWlocStateFactory._internal();

  static const _instance = _LearningSettingsPageWlocStateFactory._internal();

  factory _LearningSettingsPageWlocStateFactory() {
    return _instance;
  }

  _LearningSettingsPageWlocState create({
    required bloc.LearningSettingsPageBlocState blocState,
  }) {
    final trainingSettings = blocState.learningSettings.trainingSettings;

    final translationSelectionExerciseDisablementDisallowed =
        blocState.exerciseDisablementDisallowed &&
            trainingSettings.translationSelectionExerciseEnabled;

    final audioExerciseDisablementDisallowed =
        blocState.exerciseDisablementDisallowed && trainingSettings.audioExerciseEnabled;

    final typingExerciseDisablementDisallowed =
        blocState.exerciseDisablementDisallowed && trainingSettings.typingExerciseEnabled;

    return _LearningSettingsPageWlocState(
      autoPronunciationEnabled: blocState.learningSettings.autoPronunciationEnabled,
      exerciseShuffleEnabled: trainingSettings.exerciseShuffleEnablementEffective,
      exerciseShuffleEnablementChangePermitted:
          trainingSettings.exerciseShuffleEnablementChangePermitted,
      forgottenLexicalItemTrainingEnabled:
          trainingSettings.forgottenLexicalItemTrainingEnablementEffective,
      forgottenLexicalItemTrainingEnablementChangePermitted:
          trainingSettings.forgottenLexicalItemTrainingEnablementChangePermitted,
      exerciseEnablementChangePermitted: trainingSettings.exerciseEnablementChangePermitted,
      translationSelectionExerciseEnabled:
          trainingSettings.translationSelectionExerciseEnablementEffective,
      translationSelectionExerciseDisablementDisallowed:
          translationSelectionExerciseDisablementDisallowed,
      audioExerciseEnabled: trainingSettings.audioExerciseEnablementEffective,
      audioExerciseDisablementDisallowed: audioExerciseDisablementDisallowed,
      typingExerciseEnabled: trainingSettings.typingExerciseEnablementEffective,
      typingExerciseDisablementDisallowed: typingExerciseDisablementDisallowed,
      trainingLexicalItemMaxCountLowerLimit: blocState.trainingLexicalItemMaxCountLowerLimit,
      trainingLexicalItemMaxCountUpperLimit: blocState.trainingLexicalItemMaxCountUpperLimit,
      trainingLexicalItemMaxCount: trainingSettings.trainingLexicalItemEffectiveMaxCount,
      trainingLexicalItemMaxCountChangePermitted:
          trainingSettings.trainingLexicalItemMaxCountChangePermitted,
    );
  }
}
